import { Breadcrumb } from 'antd'
import { useLocation } from 'react-router-dom'
import style from './index.module.scss'
import { useEffect, useState } from 'react'
import { useBreadcrumb } from '@/hooks/useBreadcrumb'

export default function () {
    const { pathname } = useLocation()

    const [items, setItems] = useState<{ title: string; url: string; }[]>([])

    let breadcrumb = useBreadcrumb()
    
    useEffect(() => {
        setItems([...breadcrumb])
        // 动态设置网页title
        document.title = `🦁️${breadcrumb[breadcrumb.length - 1].title} - 歪fChat后台管理系统`
    }, [pathname])
    
    return (
        <Breadcrumb
            className={style.breadContent}
            items={items}
        >
        </Breadcrumb>
    )
}